home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / muirexx2.1 / demos / muirexxbuild / comm.rexx < prev    next >
OS/2 REXX Batch file  |  1996-08-25  |  5KB  |  169 lines

  1. /* */
  2. options results
  3. parse arg comm
  4.  
  5. /* Attribute TAG ID definitions */
  6.  
  7. List_Active =                     0x8042391c /* V4  isg LONG              */
  8. ASLFR_DrawersOnly =               0x8008002f
  9. ASLFR_InitialDrawer =             0x80080009
  10.  
  11. TRUE = 1
  12. List_Insert_Bottom = -3
  13.  
  14. address BUILD
  15.  
  16. select
  17.     when comm = 'LEFT' then do
  18.         list ID DLST ATTRS List_Active
  19.         dpos = result
  20.         list ID DLST POS dpos
  21.         gobj = substr(result,2)
  22.         parse var gobj obj .
  23.         nspc = pos(obj,gobj)-1
  24.         if nspc > 0 then do
  25.             list ID DLST POS dpos STRING '='||insert(strip(gobj),'',nspc-1)
  26.         end
  27.     end
  28.     when comm = 'RIGHT' then do
  29.         list ID DLST ATTRS List_Active
  30.         dpos = result
  31.         list ID DLST POS dpos
  32.         gobj = substr(result,2)
  33.         parse var gobj obj .
  34.         nspc = pos(obj,gobj)-1
  35.         if nspc >= 0 then do
  36.             list ID DLST POS dpos STRING '='||insert(strip(gobj),'',nspc+1)
  37.         end
  38.     end
  39.     when comm = 'COPY' then do
  40.         list ID DLST ATTRS List_Active
  41.         dpos = result
  42.         i = 0
  43.         do forever
  44.             list ID DLST
  45.             if result = '' then break
  46.             i = i + 1
  47.             line.i = result
  48.         end
  49.         do n = 1 to i
  50.             list ID DLST INSERT POS dpos+n STRING line.n
  51.         end
  52.     end
  53.     when comm = 'CREATE' then do
  54.         string ID APRT
  55.         aport = upper(result)
  56.         if aport = '' then exit
  57.         if show('ports',aport) then do
  58.             address value aport
  59.             quit
  60.             address
  61.             do while show('ports',aport)
  62.             end
  63.         end
  64.         call writemacro 't:tmp'
  65.         address command 'run >nil: MUIRexx:MUIRexx PORT 'aport' t:tmp'
  66.         address command 'delete t:tmp.rexx QUIET'
  67.     end
  68.     when comm = 'CLOSE' then do
  69.         string ID APRT
  70.         aport =  upper(result)
  71.         if show('ports',aport) then do
  72.             address value aport
  73.             quit
  74.             address
  75.         end
  76.     end
  77.     when comm = 'NEW' then do
  78.         list ID DLST STRING
  79.         list ID VLST STRING
  80.         string ID APRT CONTENT ''
  81.     end
  82.     when comm = 'SAVE' then do
  83.         getvar directory
  84.         aslrequest ID BWIN TITLE '"Select Directory"' ATTRS ASLFR_DrawersOnly TRUE ASLFR_InitialDrawer result
  85.         dir = result
  86.         if (~exists(dir)) then exit
  87.         setvar directory dir
  88.         if lastpos('/',dir) ~= length(dir) then do
  89.             if lastpos(':',dir) ~= length(dir) then dir = dir'/'
  90.         end
  91.         string ID APRT
  92.         aport = result
  93.         name = dir||aport
  94.         call writemacro name
  95.         address command 'copy build:build.info 'name'.info QUIET'
  96.     end
  97.     when comm = 'READ' then do
  98.         getvar directory
  99.         aslrequest ID BWIN TITLE '"Select File"' ATTRS ASLFR_InitialDrawer result
  100.         name = result
  101.         if (~exists(name)) then exit
  102.         if lastpos('/',name) ~= 0 then dir = substr(name,1,lastpos('/',name)-1)
  103.         else dir = substr(name,1,lastpos(':',name))
  104.         setvar directory dir
  105.         list ID DLST STRING
  106.         list ID VLST STRING
  107.         call open('file',name,'R')
  108.  
  109.         aport = ''
  110.         do while ~eof('file')
  111.             line = readln('file')
  112.             if strip(line) = '' then iterate
  113.             if index(strip(line),'/*') = 1 then iterate
  114.             if index(line,'=') > 0 then do
  115.                 parse var line vname op value .
  116.                 if strip(op) = '=' then do
  117.                     list ID VLST INSERT POS List_Insert_Bottom STRING strip(vname)' = 'strip(value)
  118.                     iterate
  119.                 end
  120.             end
  121.             if aport = '' then do
  122.                 if index(line,'address') = 1 then do
  123.                     parse var line 'address 'pname comm
  124.                     if comm = '' then do
  125.                         aport = pname
  126.                         string ID APRT CONTENT aport
  127.                         iterate
  128.                     end
  129.                 end
  130.             end
  131.             list ID DLST INSERT POS List_Insert_Bottom STRING '='||line
  132.         end
  133.         call close('file')
  134.     end
  135.     otherwise nop
  136. end
  137.  
  138. exit
  139.  
  140. writemacro: procedure
  141. parse arg name
  142.  
  143. string ID APRT
  144. aport = result
  145. call open('file',name'.rexx','W')
  146. call writeln('file','/* Application created by MUIBuild */')
  147. call writeln('file','')
  148. call writeln('file','address 'aport)
  149. call writeln('file','')
  150. i = 0
  151. do forever
  152.     list ID VLST POS i
  153.     line = result
  154.     if line = '' then break
  155.     call writeln('file',line)
  156.     i = i + 1
  157. end
  158. call writeln('file','')
  159. i = 0
  160. do forever
  161.     list ID DLST POS i
  162.     line = result
  163.     if line = '' then break
  164.     call writeln('file',substr(line,2))
  165.     i = i + 1
  166. end
  167. call close('file')
  168. return
  169.